# Contributor (MSYS2): David Macek <david.macek.0@gmail.com>
# Maintainer (Arch Linux): Alexander Rødseth <rodseth@gmail.com>
# Contributor (Arch Linux): Angel 'angvp' Velasquez <angvp[at]archlinux.com.ve>  
# Contributor (Arch Linux): djgera
# Contributor (Arch Linux): Patrick Melo <patrick@patrickmelo.eti.br>

_realname=geany-plugins
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.36.0
pkgrel=1
pkgdesc='Plugins for Geany (mingw-w64)'
arch=('any')
url='https://plugins.geany.org/'
license=('GPL')
depends=("${MINGW_PACKAGE_PREFIX}-geany>=${pkgver}"
         "${MINGW_PACKAGE_PREFIX}-discount"
         "${MINGW_PACKAGE_PREFIX}-gtkspell3"
         "${MINGW_PACKAGE_PREFIX}-ctpl"
         "${MINGW_PACKAGE_PREFIX}-gpgme"
#         "${MINGW_PACKAGE_PREFIX}-vte"
         "${MINGW_PACKAGE_PREFIX}-lua51"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libgit2"
         "${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme")
makedepends=('intltool'
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gdb"
             "${MINGW_PACKAGE_PREFIX}-gcc")
#             "${MINGW_PACKAGE_PREFIX}-cppcheck")
# optdepends=("${MINGW_PACKAGE_PREFIX}-hspell: hebrew spell checker")
install="${_realname}-${CARCH}.install"
source=(#"https://plugins.geany.org/${_realname}/${_realname}-${pkgver}.tar.bz2"
        ${_realname}-${pkgver}.tar.gz::https://github.com/geany/geany-plugins/archive/${pkgver}.tar.gz
        001-no-undefined.patch)
sha256sums=('39409e948502a7d6d88a290f201b7c6c678ce8ecaff7c73589ee0f6dcc059568'
            '8f1f6ddcdb180e44cafe2ed0b30a120ec5c89ff7ac8b7833d8da7fdb328a370a')
noextract=(${_realname}-${pkgver}.tar.gz)

prepare() {
  [[ -d ${srcdir}/${_realname}-${pkgver} ]] && rm -rf ${srcdir}/${_realname}-${pkgver}
  tar -xzvf ${srcdir}/${_realname}-${pkgver}.tar.gz -C ${srcdir} || true
  cd ${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-no-undefined.patch
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  rm -rf "build-${MINGW_CHOST}"
  mkdir -p "build-${MINGW_CHOST}"
  cd "build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --disable-geanypy \
    --disable-static

  make
}

package() {
  cd "build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
